const app = getApp()
import {
  ApiGetExamineReportDetail,
  ApiDoctorExamineReportDetail
} from "../../pagesDoctor/api/index"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    time: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */

  async onLoad(options) {
    console.log('options.isDoctor',options.isDoctor)
    let detail = ""
    let image = ""
    options.time ? detail = JSON.parse(decodeURIComponent(options.time)) : image = JSON.parse(decodeURIComponent(options.image))
    this.setData({
      /*     userInfo: await app.getUserInfo(), */
      time: detail,
      image: image,
      isDoctor: options.isDoctor
    })
    if (detail.WorksheetId) {
      this.reportDetail(detail)
    }

  },
  reportDetail(val) {
    this.setData({
      loading: true,
    })
    let list = []
    console.log(this.data.isDoctor)
    if (this.data.isDoctor=='false') {
      ApiGetExamineReportDetail({
        worksheetId: val.WorksheetId
      }).then(res => {
        !Array.isArray(res.data) ? list.push(res.data) : list = res.data;
        list[0].detail = val

        console.log('listlistlist', list)
        this.setData({
          time: list,
          loading: false,
        })
      }).finally(_=>{
        this.setData({
          loading: false
        })
      })
    }else {
      ApiDoctorExamineReportDetail({
        worksheetId: val.WorksheetId
      }).then(res => {
        !Array.isArray(res.data) ? list.push(res.data) : list = res.data;
        list[0].detail = val
        this.setData({
          time: list,
          loading: false,
        })
      })
    }
  },

  onClick() {
    // wx.previewImage({
    //   urls: ['/assets/image/mzbg.png'],
    // })
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})